//package com.shenfc.fxzj.service.impl;
//
//import org.springframework.beans.BeansException;
//import org.springframework.context.ApplicationContext;
//import org.springframework.context.ApplicationContextAware;
//import org.springframework.context.EnvironmentAware;
//import org.springframework.core.env.Environment;
//import org.springframework.stereotype.Component;
//import service.BlogTypeService;
//
//import javax.servlet.ServletContext;
//import javax.servlet.ServletContextEvent;
//import javax.servlet.ServletContextListener;
//import java.util.Iterator;
//import java.util.List;
//
///**
// * 初始化组件 把博主信息 根据博客类别分类信息 根据日期归档分类信息 存放到application中，用以提供页面请求性能
// *
// * @author Administrator
// */
//@Component
//public class InitComponent implements ServletContextListener, ApplicationContextAware, EnvironmentAware {
//
//    private static ApplicationContext applicationContext;
//
//    private static Environment environment;
//
//    @Override
//    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//        // TODO Auto-generated method stub
//        this.applicationContext = applicationContext;
//    }
//
//    @Override
//    public void contextInitialized(ServletContextEvent servletContextEvent) {
//        ServletContext application = servletContextEvent.getServletContext();
//
//        BlogTypeService blogTypeService = (BlogTypeService) applicationContext.getBean("blogTypeService");
//        List<BlogType> blogTypeCountList = blogTypeService.queryBlogTypeList(); // 查询博客类别以及博客的数量
//        Iterator<BlogType> iterator = blogTypeCountList.iterator();
//        application.setAttribute("blogTypeCountList", blogTypeCountList);
//
//    }
//
//    @Override
//    public void contextDestroyed(ServletContextEvent sce) {
//        // TODO Auto-generated method stub
//
//    }
//
//    @Override
//    public void setEnvironment(Environment environment) {
//        this.environment = environment;
//    }
//}
